@extends('layout.main')

@section('content')
<!-- PAGE CONTENT BEGINS -->

<div class="row">
	<div class="col-xs-12">
		<!-- PAGE CONTENT BEGINS -->
		<form class="form-horizontal" id="myform" role="form" method="post" action='/menu/add'>
			<!-- #section:elements.form -->
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 control-label no-padding-right" for="name">名称：</label>

				<div class="col-xs-12 col-sm-9">
				<div class="clearfix">
					<input type="text" id="name" name="name" class="col-xs-10 col-sm-5" />
				</div>
				</div>
			</div>

			<div class="space-4"></div>

			<div class="form-group">
				<label class="col-xs-12 col-sm-3 control-label no-padding-right" for="form-input-readonly">父级分类：</label>
				
				<div class="col-xs-12 col-sm-9">
				<div class="clearfix">
					<input readonly="" type="text" class="col-xs-10 col-sm-5" value="{{$info['ptype']->name}}" /></div>
				<input type="hidden" name="pid" value="{{$info['ptype']->id}}">
			</div>
		</div>

			<!-- /section:elements.form -->

			<div class="space-4"></div>

			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right" for="tagIn">所属网站：</label>

				<div class="col-sm-9">
					<!-- #section:plugins/input.tag-input -->
					<div class="cols-sm-9">
						<select class="form-control" id="site_id" name="site_id">
							<option value="">请选择</option>
							@foreach ($info['sites'] as $site)
							<option value="{{$site->id}}">{{$site->name}}</option>
							@endforeach
						</select>

					</div>

					<!-- /section:plugins/input.tag-input -->
				</div>
			</div>

			<div class="space-4"></div>

			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right" for="status_at">启用：</label>
				<div class="col-sm-9">
					<input type="checkbox" id="status_at" name="status_at" checked></div>
			</div>

			{!! csrf_field() !!}

			<div class="clearfix form-actions">
				<div class="col-md-offset-3 col-md-9">
					<button class="btn btn-info" type="submit"> <i class="ace-icon fa fa-check bigger-110"></i>
						提交
					</button>
					&nbsp; &nbsp; &nbsp;
					<button class="btn" type="reset"> <i class="ace-icon fa fa-undo bigger-110"></i>
						重置
					</button>
				</div>
			</div>
		</form>

		<!-- PAGE CONTENT ENDS -->
	</div>
	<!-- /.col -->
</div>
<!-- /.row -->

<!-- PAGE CONTENT ENDS -->
@endsection



@section('js')
<script type="text/javascript"> 
jQuery(function($) {
	$("#status_at").bootstrapSwitch();
	// $('#sort').ace_spinner({value:0,min:0,max:999,step:1, btn_up_class:'btn-info' , btn_down_class:'btn-info'}); 
	//handle form onsubmit event to send the wysiwyg's content to server
	$('#myform').on('submit', function() {
		$status_at = $("#status_at");
		var status = $status_at.bootstrapSwitch('state');
		if (status) {
			$status_at.val('1');
		} else {
			$status_at.val('0');
		}
		return true;
	});

	$('#myform').on('reset', function() {
		$('#editor').empty();
	});

	 $('#myform').validate({
                    errorElement: 'div',
                    errorClass: 'help-block',
                    focusInvalid: false,
                    ignore: "",
                    rules: {
                        name: {
                            required: true
                        }
                    },
                    messages: {
                        name: "请填写名称"                        
                    },
            
            
                    highlight: function (e) {
                        $(e).closest('.form-group').removeClass('has-info').addClass('has-error');
                    },
            
                    success: function (e) {
                        $(e).closest('.form-group').removeClass('has-error');//.addClass('has-info');
                        $(e).remove();
                    }
                });
});
</script>
@endsection